﻿using PHMEE.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace PHMEE
{
    public class PHMEEAdminPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var phmeeadminGroup = context.AddGroup(PHMEEAdminPermissions.GroupName);


            var companyPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Companies.Default, L("Permission:CompanyManagement"));
            companyPermission.AddChild(PHMEEAdminPermissions.Companies.Create, L("Permission:Create"));
            companyPermission.AddChild(PHMEEAdminPermissions.Companies.Update, L("Permission:Update"));
            companyPermission.AddChild(PHMEEAdminPermissions.Companies.Delete, L("Permission:Delete"));

            var fleetPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Fleets.Default, L("Permission:FleetManagement"));
            fleetPermission.AddChild(PHMEEAdminPermissions.Fleets.Create, L("Permission:Create"));
            fleetPermission.AddChild(PHMEEAdminPermissions.Fleets.Update, L("Permission:Update"));
            fleetPermission.AddChild(PHMEEAdminPermissions.Fleets.Delete, L("Permission:Delete"));

            var vesselPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Vessels.Default, L("Permission:VesselManagement"));
            vesselPermission.AddChild(PHMEEAdminPermissions.Vessels.Create, L("Permission:Create"));
            vesselPermission.AddChild(PHMEEAdminPermissions.Vessels.Update, L("Permission:Update"));
            vesselPermission.AddChild(PHMEEAdminPermissions.Vessels.Delete, L("Permission:Delete"));

            var unitPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Units.Default, L("Permission:UnitManagement"));
            unitPermission.AddChild(PHMEEAdminPermissions.Units.Create, L("Permission:Create"));
            unitPermission.AddChild(PHMEEAdminPermissions.Units.Update, L("Permission:Update"));
            unitPermission.AddChild(PHMEEAdminPermissions.Units.Delete, L("Permission:Delete"));

            var equipmentPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Equipments.Default, L("Permission:EquipmentManagement"));
            equipmentPermission.AddChild(PHMEEAdminPermissions.Equipments.Create, L("Permission:Create"));
            equipmentPermission.AddChild(PHMEEAdminPermissions.Equipments.Update, L("Permission:Update"));
            equipmentPermission.AddChild(PHMEEAdminPermissions.Equipments.Delete, L("Permission:Delete"));

            var componentPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Components.Default, L("Permission:ComponentManagement"));
            componentPermission.AddChild(PHMEEAdminPermissions.Components.Create, L("Permission:Create"));
            componentPermission.AddChild(PHMEEAdminPermissions.Components.Update, L("Permission:Update"));
            componentPermission.AddChild(PHMEEAdminPermissions.Components.Delete, L("Permission:Delete"));

            var pointPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.Points.Default, L("Permission:PointManagement"));
            pointPermission.AddChild(PHMEEAdminPermissions.Points.Create, L("Permission:Create"));
            pointPermission.AddChild(PHMEEAdminPermissions.Points.Update, L("Permission:Update"));
            pointPermission.AddChild(PHMEEAdminPermissions.Points.Delete, L("Permission:Delete"));

            var mainenanceAdvicePermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.MainenanceAdvices.Default, L("Permission:MainenanceAdvice"));
            mainenanceAdvicePermission.AddChild(PHMEEAdminPermissions.MainenanceAdvices.Create, L("Permission:Create"));
            mainenanceAdvicePermission.AddChild(PHMEEAdminPermissions.MainenanceAdvices.Update, L("Permission:Update"));
            mainenanceAdvicePermission.AddChild(PHMEEAdminPermissions.MainenanceAdvices.Delete, L("Permission:Delete"));

            var bearFactoryPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.BearFactories.Default, L("Permission:BearFactory"));
            bearFactoryPermission.AddChild(PHMEEAdminPermissions.BearFactories.Create, L("Permission:Create"));
            bearFactoryPermission.AddChild(PHMEEAdminPermissions.BearFactories.Update, L("Permission:Update"));
            bearFactoryPermission.AddChild(PHMEEAdminPermissions.BearFactories.Delete, L("Permission:Delete"));

            var bearLibPermission = phmeeadminGroup.AddPermission(PHMEEAdminPermissions.BearLibs.Default, L("Permission:BearLib"));
            bearLibPermission.AddChild(PHMEEAdminPermissions.BearLibs.Create, L("Permission:Create"));
            bearLibPermission.AddChild(PHMEEAdminPermissions.BearLibs.Update, L("Permission:Update"));
            bearLibPermission.AddChild(PHMEEAdminPermissions.BearLibs.Delete, L("Permission:Delete"));
            bearLibPermission.AddChild(PHMEEAdminPermissions.BearLibs.DownloadTemplateExcel, L("Permission:DownloadTemplateExcel"));
            bearLibPermission.AddChild(PHMEEAdminPermissions.BearLibs.ImportExcel, L("Permission:ImportExcel"));

        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<PHMEEResource>(name);
        }
    }
}
